import java.util.HashSet;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        String s = "abcde";
        char[] arr = s.toCharArray();
        arr[0] = 'x';
        s = String.valueOf(arr);
        System.out.println(s);
        Set<Character> set = new HashSet<>();


    }
    //1576去掉字符串中所有的问号
    public String modifyString(String s) {
        char[] arr = s.toCharArray();
        for(int i=1;i<arr.length-1;i++) {
            char tmp = arr[i];
            if(tmp == '?') {
                char ch = 'a';
                while(ch==arr[i-1]||ch==arr[i+1]) {
                    ch = (char)(ch+1);
                }
                arr[i] = ch;
            }
        }
        if(arr.length == 1 && arr[0]=='?') {
            arr[0] = 'a';
        }
        if(arr[0]=='?') {
            char ch = 'a';
            while(ch==arr[1]) {
                ch = (char)(ch+1);
            }
            arr[0] = ch;
        }
        if(arr[arr.length-1]=='?') {
            char ch = 'a';
            while(ch==arr[arr.length-2]) {
                ch = (char)(ch+1);
            }
            arr[arr.length-1] = ch;
        }
        s = String.valueOf(arr);
        return s;

    }
    //使用数据结构解法
    public boolean isUnique1(String astr) {
        Set<Character> set = new HashSet<>();
        for(int i=0;i<astr.length();i++) {
            char ch = astr.charAt(i);
            if(set.contains(ch)) {
                return false;
            }
            set.add(ch);
        }
        return true;
    }
    //使用位运算解法-位图的思想
    public boolean isUnique(String astr) {
        int l = 0;
        for(int i =0;i<astr.length();i++) {
            int ch = astr.charAt(i)-97;
            if(((l>>ch)&1)==1) {
                return false;
            }
            l = l | (1<<ch);
        }
        return true;
    }


}
